package examples;

import com4j.Variant;
import msexcel.*;

/**
 * @author yuan zhen chao
 * @date 2019/11/27
 */
public class ExcelSaveAsPdf {
    public static void main(String[] args) {
        _Application app = ClassFactory.createApplication();

        app.visible(0, false);
        app.displayAlerts(0, false);
        String inPath = "D:\\1.xlsx";
        String outpath = "D:\\1.pdf";

        try {
            _Workbook book = app.workbooks().open(inPath, Variant.getMissing(), true, Variant.getMissing(), Variant.getMissing(),
                    Variant.getMissing(), Variant.getMissing(), Variant.getMissing(), Variant.getMissing(), Variant.getMissing(),
                    Variant.getMissing(), Variant.getMissing(), Variant.getMissing(), Variant.getMissing(), Variant.getMissing(), 0);
        book.exportAsFixedFormat(XlFixedFormatType.xlTypePDF, outpath, XlFixedFormatQuality.xlQualityMinimum, Variant.getMissing(),
                Variant.getMissing(), Variant.getMissing(), Variant.getMissing(), Variant.getMissing(), Variant.getMissing());
        book.close(true, Variant.getMissing(), Variant.getMissing(), 0);
        } catch (Exception e) {
            e.printStackTrace();
        }
//        app.quit();
    }
}
